﻿using System;
using System.Data;
using MySql.Data.MySqlClient;

namespace Catequese.Classes
{
    class BaseDados
    {
        private string hostname;
        private string username;
        private string password;
        private string database;
        private int port;

        private string _connectionString;

        public MySqlConnection myConnection;
        public MySqlCommand myCommand;
        public MySqlDataReader myReader;
        public MySqlDataAdapter myAdapter;

        public BaseDados()
        {
            hostname = Catequese.Properties.Settings.Default.DB_HOSTNAME;
            username = Catequese.Properties.Settings.Default.DB_USERNAME;
            password = Catequese.Properties.Settings.Default.DB_PASSWORD;
            database = Catequese.Properties.Settings.Default.DB_DATABASE;
            port = Catequese.Properties.Settings.Default.DB_PORT;

            _connectionString = "server=" + hostname + ";Port=" + port + ";User Id=" + username + ";password=" + password + ";database=" + database + ";Persist Security Info=True;Allow Zero Datetime=True;Convert Zero Datetime=True";

            myConnection = new MySqlConnection(_connectionString);
        }

        public string connectionString
        {
            get
            {
                return _connectionString;
            }
        }
    }
}
